#include "SwordMan.h"
#include "../data/GameInfo.h"

SwordMan::SwordMan()
{
    skillList = {SkillId::SKILL_RASENGAN, SkillId::SKILL_PURPLE_ENERGY,
                 SkillId::SKILL_CHIDORI, SkillId::SKILL_RASENSHURIKEN, SkillId::SKILL_WHIRL_WIND};
    GameAnimation::InitFrameData(GameInfo::Instance().texturePool[TexId::TEX_SWORDMAN_ATTACK],
                                 animAttack, 4, 8, false, nullptr, 0.05);
    GameAnimation::InitFrameData(GameInfo::Instance().texturePool[TexId::TEX_SWORDMAN_DIE],
                                 animDie, 4, 3, false, [this] { OnDie(); }, 0.1);
    GameAnimation::InitFrameData(GameInfo::Instance().texturePool[TexId::TEX_SWORDMAN_STANDBY],
                                 animStandBy, 4, 1);
    GameAnimation::InitFrameData(GameInfo::Instance().texturePool[TexId::TEX_SWORDMAN_WALK],
                                 animWalk, 4, 4);

    for (int i = 0; i < Facing::SIZE; i++) {
        animRigidity[i].Copy(animStandBy[i]);
        animRigidity[i].rectSrcList = {animStandBy[i].rectSrcList[0]};
        animRigidity[i].timer.waitTime = 1;
        animRigidity[i].isLoop = false;
        animRigidity[i].onFinished = [this] { OnRigidity(); };
        animRelease[i].Copy(animAttack[i]);
        animRelease[i].rectSrcList = {animAttack[i].rectSrcList[0], animAttack[i].rectSrcList[1],
                                      animAttack[i].rectSrcList[2], animAttack[i].rectSrcList[3]};
        animChant[i].Copy(animAttack[i]);
        animChant[i].rectSrcList = {animAttack[i].rectSrcList[0], animAttack[i].rectSrcList[1],
                                    animAttack[i].rectSrcList[2], animAttack[i].rectSrcList[3]};
    }

    attackMix = GameInfo::Instance().mixPool[MixId::MIX_SWORD_ATTACK];
}